<!DOCTYPE html>
<html lang="zh-cn">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <title>登录-{{.site_name}}</title>
    <script>
        if (window != window.top) top.location.href = self.location.href;
    </script>
    <link href="{{.kit_admin}}/plugins/layui/css/layui.css" rel="stylesheet" />
    <link href="{{.kit_admin}}/plugins/font-awesome/css/font-awesome.css" rel="stylesheet" />
    <link href="{{.kit_admin}}/build/css/login.css" rel="stylesheet" />
    <link href="{{.kit_admin}}/plugins/sideshow/css/normalize.css" rel="stylesheet" />
    <link href="{{.kit_admin}}/plugins/sideshow/css/demo.css" rel="stylesheet" />
    <link href="{{.kit_admin}}/plugins/sideshow/css/component.css" rel="stylesheet" />
    <!--[if IE]>
    <script src="{{.kit_admin}}/plugins/sideshow/js/html5.js"></script>
    <![endif]-->
    <style>
        canvas {
            position: absolute;
            z-index: -1;
        }

        .kit-login-box header h1 {
            line-height: normal;
        }

        .kit-login-box header {
            height: auto;
        }

        .content {
            position: relative;
        }

        .codrops-demos {
            position: absolute;
            bottom: 0;
            left: 40%;
            z-index: 10;
        }

        .codrops-demos a {
            border: 2px solid rgba(242, 242, 242, 0.41);
            color: rgba(255, 255, 255, 0.51);
        }

        .kit-pull-right button,
        .kit-login-main .layui-form-item input {
            background-color: transparent;
            color: white;
        }

        .kit-login-main .layui-form-item input::-webkit-input-placeholder {
            color: white;
        }

        .kit-login-main .layui-form-item input:-moz-placeholder {
            color: white;
        }

        .kit-login-main .layui-form-item input::-moz-placeholder {
            color: white;
        }

        .kit-login-main .layui-form-item input:-ms-input-placeholder {
            color: white;
        }

        .kit-pull-right button:hover {
            border-color: #009688;
            color: #009688
        }

        .form-code img{
            height: 34px;
            background-color: #fff;
        }
    </style>
</head>


<body class="kit-login-bg">
<div class="container demo-1">
    <div class="content">
        <div id="large-header" class="large-header">
            <canvas id="demo-canvas"></canvas>
            <div class="kit-login-box">
                <header>
                    <h1>{{.site_name}} 登录</h1>
                </header>
                <div class="kit-login-main">
                    <form action="#" class="layui-form" method="post">
                        <div class="layui-form-item">
                            <label class="kit-login-icon">
                                <i class="layui-icon">&#xe612;</i>
                            </label>
                            <input type="text" name="username" value="" lay-verify="required" autocomplete="off" placeholder="这里输入用户名." class="layui-input">
                        </div>
                        <div class="layui-form-item">
                            <label class="kit-login-icon">
                                <i class="layui-icon">&#xe642;</i>
                            </label>
                            <input type="password" name="password" value="" lay-verify="required" autocomplete="off" placeholder="这里输入密码." class="layui-input">
                        </div>
                        <div class="layui-form-item">
                            <label class="kit-login-icon">
                                <i class="layui-icon">&#xe642;</i>
                            </label>
                            <input type="text" name="validcode" lay-verify="" autocomplete="off" placeholder="输入验证码" class="layui-input">
                            <span class="form-code" id="changeCode" style="position:absolute;right:2px; top:2px;">
                                    <img src="/captcha/{{.CaptchaId}}.png" id="refImg" height="80" style="cursor:pointer;" title="点击刷新"/>
                                </span>
                        </div>
                        <div class="layui-form-item">
                            <div class="kit-pull-left kit-login-remember">
                                <input type="checkbox" name="rememberMe" value="true" lay-skin="primary" checked title="记住帐号?">
                            </div>
                            <div class="kit-pull-right">
                                <button class="layui-btn layui-btn-primary" lay-submit lay-filter="login">
                                    <i class="fa fa-sign-in" aria-hidden="true"></i> 登录
                                </button>
                            </div>
                            <div class="kit-clear"></div>
                        </div>
                    </form>
                </div>
                <footer>
                    <p>Go Mail Micro Service © <a href="#" style="color:white; font-size:18px;" target="_blank">zhucheer</a></p>
                </footer>
            </div>
        </div>
    </div>
</div>
<!-- /container -->

<script src="{{.kit_admin}}/plugins/layui/layui.js"></script>
<script src="{{.kit_admin}}/plugins/sideshow/js/TweenLite.min.js"></script>
<script src="{{.kit_admin}}/plugins/sideshow/js/EasePack.min.js"></script>
<script src="{{.kit_admin}}/plugins/sideshow/js/rAF.js"></script>
<script src="{{.kit_admin}}/plugins/sideshow/js/demo-1.js"></script>
<script>

    layui.use(['layer', 'form'], function() {
        {{template "layout/baseJs.html" .}}
        var layer = layui.layer,
                $ = layui.jquery,
                form = layui.form;


        $('#changeCode').on('click', function() {
            refreshCode();
        });






        $(window).on('load', function() {
            refreshCode();

            form.on('submit(login)', function(data) {
                var param = $('.layui-form').serialize();
                var url = "/login";

                layer.load(2);
                $.ajax({
                    type: "POST",
                    url: url,
                    data: param,
                    success: function(json){
                        refreshCode();
                        if(json.status != 200){
                            layer.closeAll('loading');
                            //layer.msg(json.info);
                            QI.errorAlert(json.info);
                            return false;
                        }
                        layer.closeAll();
                        QI.successAlert(json.info);
                        if(json.data.url){
                            QI.delayJump(json.data.url);
                        }else{
                            QI.delayJump('');
                        }

                    },
                    error:function(e){
                        layer.closeAll('loading');
                        refreshCode();
                        QI.errorAlert('系统出小差了（'+e.statusText+'）');
                    }
                });

                return false;
            });
        }());


        function refreshCode(){
            var stamp=Date.parse(new Date());
            $.ajax({
                type: "GET",
                url: "/captcha-id",
                data: {_t:stamp},
                success: function(json){
                    if(json.status != 200){
                        layer.closeAll('loading');
                        QI.errorAlert(json.info);
                        return false;
                    }
                    $('#changeCode > img')[0].src = json.data;
                },
                error:function(e){
                    QI.errorAlert('系统出小差了（'+e.statusText+'）');
                }
            });
        }

    });



</script>
</body>

</html>